/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package queenb.web.controller.user;

import java.util.List;
import queenb.net.entitybean.S250;
import queenb.web.controller.QueenbController;
import queenb.web.store.S250Store;
import queenb.web.util.Util;

/**
 *
 * @author VANANH
 */
public class S250Controller extends QueenbController {

    private int PS250;
    private String SV251;
    private String SV252;
    private S250Store s250Store;

    public S250Controller() {
        s250Store = new S250Store();
        Object ps250Object = getRequest().getParameter("ps250");
        try {
            if (ps250Object != null) {
                this.PS250 = Util.parseInt(ps250Object);
                getListS250DetailEdit(PS250);
            }
        }catch(Exception ex)
        {
            
        }
    }

    public void getListS250DetailEdit(int pv200i) {
        this.PS250 = pv200i;
        try {
            List<S250> listS250ByID = getListS250All();
            if (listS250ByID.size() > 0) {
                for (int i = 0; i < listS250ByID.size(); i++) {
                    if (listS250ByID.get(i).getPS250() == PS250) {
                        this.SV251 = listS250ByID.get(i).getSV251();
                        this.SV252 = listS250ByID.get(i).getSV252();

                        break;
                    }
                }
            }
        } catch (Exception ex) {
            System.out.println("ERROR : " + ex.getMessage());
        }

    }

    public List<S250> getListS250All() {
        try {
            List<S250> listS250 = s250Store.getListS200All(getLogin().getModule(), getLogin().getCompanyNo(), getLogin().getUserName());
            return listS250;
        } catch (Exception ex) {
            return null;

        }
    }

    public void update() {
        int count = s250Store.updateS250(getLogin().getModule(), getLogin().getCompanyNo(), PS250, 0, 0, SV251, SV252, null, null, 0, 0, getLogin().getUserName());
        if (count > 0) {
            showGlobalReport(true, getResourceString("datasavesuccessful"));
        } else {
            showGlobalReport(true, getResourceString("datasuccessfail"));
        }
        sendRedirectUrlTab("setting.jsp?tab=header8&"+Util.convertMD5(getRequest().getRequestURI()));
    }

    /**
     * @return the PS250
     */
    public int getPS250() {
        return PS250;
    }

    /**
     * @param PS250 the PS250 to set
     */
    public void setPS250(int PS250) {
        this.PS250 = PS250;
    }

    /**
     * @return the SV251
     */
    public String getSV251() {
        return SV251;
    }

    /**
     * @param SV251 the SV251 to set
     */
    public void setSV251(String SV251) {
        this.SV251 = SV251;
    }

    /**
     * @return the SV252
     */
    public String getSV252() {
        return SV252;
    }

    /**
     * @param SV252 the SV252 to set
     */
    public void setSV252(String SV252) {
        this.SV252 = SV252;
    }
}
